﻿using System;
using System.Reflection;

namespace Borg
{
    [Serializable]
    public class Plugin : AssemblyElement
    {
        [NonSerialized]
        private AppDomain _appDomain;
        private MetaElementCollection<ExtensionType> _extensionTypes;

        public AppDomain AppDomain
        {
            get { return _appDomain; }
            internal set { _appDomain = value; }
        }

        public MetaElementCollection<ExtensionType> ExtensionTypes
        {
            get { return _extensionTypes; }
            internal set { _extensionTypes = value; }
        }

        public override bool IsQualified
        {
            get { return Qualifier.IsQualified(this); }
        }

        internal Plugin(string analyzerId, Runtime runtime, int id, string name,
            Uri originUri, Assembly assembly, Uri environmentUri)
            : base(analyzerId, runtime, id, name, originUri, assembly, environmentUri)
        {
            runtime.Loader.InternalSetAssembly(this, assembly);
        }

        internal Plugin(string analyzerId, Runtime runtime, int id, string name,
            Uri originUri, Uri assemblyUri, Uri environmentUri)
            : base(analyzerId, runtime, id, name, originUri, assemblyUri, environmentUri)
        { }

        public override bool Qualify()
        {
            return Qualifier.Qualify(this);
        }
    }
}
